package com.jiayu.seckilldemo.controller;


import com.jiayu.seckilldemo.pojo.User;
import com.jiayu.seckilldemo.rabbitmq.MQSender;
import com.jiayu.seckilldemo.service.IUserService;
import com.jiayu.seckilldemo.vo.RespBean;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jiayu
 * @since 2022-07-20
 */
@Controller
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    private IUserService userService;
    @Autowired
    private MQSender mqSender;

    @RequestMapping(value = "/info", method = RequestMethod.GET)
    @ResponseBody
    public RespBean info(User user) {
        return RespBean.success(user);
    }

    @RequestMapping("/mq")
    @ResponseBody
    public void mq(){
        mqSender.sendSeckillMessage("hello");
    }


    @RequestMapping("/mq/fanout")
    @ResponseBody
    public void mq01(){
        mqSender.send01("hello");
    }

    @RequestMapping("/mq/direct01")
    @ResponseBody
    public void mq02(){
        mqSender.send02("hello,red");
    }
    @RequestMapping("/mq/direct02")
    @ResponseBody
    public void mq03(){
        mqSender.send03("hello,green");
    }

    @RequestMapping("/mq/topic01")
    @ResponseBody
    public void mq04(){
        mqSender.send04("hello,red topic");
    }

    @RequestMapping("/mq/topic02")
    @ResponseBody
    public void mq05(){
        mqSender.send04("hello,green topic");
    }


}
